const config = require('../../common/config');
const util = require('./../../utils/util');

Page({
    data:{
        special:[],
        hasData:false
    },
    onLoad:function (opt) {
        var typeId = opt.typeId;
        var typeName = opt.typeName;
        var that = this;
        wx.setNavigationBarTitle({
            title: typeName
        })

        wx.request({
            url: config.COMMPT_REQPATH,
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            method:'POST',
            data: {
                accessToken: '',
                refreshToken: '',
                serviceName: 'wxShopManageService',
                methodName: 'getShopList',
                reqData:JSON.stringify({
                    sortType: '4',
                    shopType:typeId,
                    latitute:wx.getStorageSync(config.LOC_LATITUDE),
                    longitude:wx.getStorageSync(config.LOC_LONGITUDE)
                })
            },
            success: function (res) {
                var resultData = res.data;

                if(resultData.code == 1){
                    var bzShopList = resultData.data.bzShopList;
                    if(bzShopList.length>0){
                        that.setData({
                            special: bzShopList,
                            hasData:true
                        })
                    }else {
                        that.setData({
                            special: [],
                            hasData:false
                        })
                    }
                }
            },
            fail:function (errResult) {
                that.setData({
                    special: [],
                    hasData:false
                })
                util.debug(errResult);
            }
        })
    }
})